import { ipcRenderer } from "electron";
import { Method } from "axios";
import { RequestOptions } from "../../main/requestService";

const requestApi = {
  /**
   * 发送 HTTP GET 请求
   */
  get: (url: string, options?: RequestOptions) => ipcRenderer.invoke('request:get', url, options),

  /**
   * 发送 HTTP POST 请求
   */
  post: (url: string, options?: RequestOptions) => ipcRenderer.invoke('request:post', url, options),

  /**
   * 发送 HTTP PUT 请求
   */
  put: (url: string, options?: RequestOptions) => ipcRenderer.invoke('request:put', url, options),

  /**
   * 发送 HTTP DELETE 请求
   */
  delete: (url: string, options?: RequestOptions) => ipcRenderer.invoke('request:delete', url, options),

  /**
   * 发送任意 HTTP 方法请求
   */
  send: (method: Method, url: string, options?: RequestOptions) => ipcRenderer.invoke('request:send', method, url, options),
};

export default requestApi;